//
//  keypoint_detector.hpp
//  yuzon
//
//  Created by Alvin on 2023/3/29.
//

#pragma once

#include <opencv2/opencv.hpp>
#include "paddle_api.h"
#include "common.hpp"

class KeypointDetector {
public:
  explicit KeypointDetector(const std::string &model_keypoint_path);
  void Predict(const cv::Mat &image,
               const HumanResults &human_results,
               KeypointResults &keypoint_results);
  
private:
  void CropImage(const cv::Mat &image,
                 const HumanResults &results,
                 std::vector<cv::Mat> &crops,
                 std::vector<cv::Point2f> &centers,
                 std::vector<cv::Size2f> &scales);
  void Preprocess(const std::vector<cv::Mat> &crops);
  void Postprocess(const cv::Mat &image,
                   const std::vector<cv::Point2f> &centers,
                   const std::vector<cv::Size2f> &scales,
                   KeypointResults &results);
  
  int input_width_;
  int input_height_;
  bool dark_;
  std::shared_ptr<paddle::lite_api::PaddlePredictor> predictor_;
};
